import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import './provide/details_info_provide.dart';
import './pages/details/details_top_area.dart';
import './pages/details/details_explain.dart';
import './pages/details/details_tabbar.dart';
import './pages/details/details_wep.dart';
import './pages/details/details_fotter.dart';


class DetailsPage extends StatelessWidget {
  final String goodsId ;
  DetailsPage(this.goodsId);

  @override
  Widget build(BuildContext context) {
    _getBackInfo(context);
    return Scaffold(
      appBar: AppBar(
        title:Text('商品详情'),
        leading: IconButton(
          icon: Icon(Icons.arrow_back),
          onPressed: (){
            Navigator.pop(context);
          },
        ),
      ),
      body: FutureBuilder(
        future: _getBackInfo(context),
        builder:(context,snapshot){
          if(snapshot.hasData){
            return Stack(
              children: <Widget>[
                Container(
                  child: ListView(
                    children: <Widget>[
                        DetailsTopArea(),
                        DetailExplain(),
                        DetailsTabbar(),
                        DetailsWep(),
                        Container(
                          // margin: EdgeInsets.only(bottom:100.0),
                        )
                    ],
                  ),
                ),
                // 定位组件
                Positioned(
                  bottom: 0,
                  left:0,
                  child: DetailsFotter(),
                )
              ],
            ) ;
          }else{
            return Text('加载中...');
          }
        }),
    );
  }
  Future _getBackInfo(BuildContext context) async{
    await Provide.value<DetailsProviedInfo>(context).getGoodsInfo(goodsId);
    return '完成加载';
  }
}